import {getDicts} from "@/api/system/dict/data";
import {listCompassUniversityInfo} from "@/api/system/CompassUniversityInfo";
import importData from "@/components/importData";
export default {
  components: {
    importData
  },
  mounted() {

  },

  methods: {
    async getDictByTypeName(name) {
      if (!name) return []
      let res = await getDicts(name)
      return res.data
    },

    async queryAutoSearchAsync(queryString, cb) {
      var restaurants = await listCompassUniversityInfo({
        pageNum: 1,
        pageSize: 10,
        schoolName: queryString
      });
      if (!restaurants.rows.length) {
        cb([{
          schoolName: '没有匹配院校，去添加',
          schoolCode: -1
        }])
      } else {
        cb(restaurants.rows)
      }
    },

    handleAutoSelect(res) {
      if (res.schoolCode != -1) {
        this.form.schoolName = res.schoolName
        this.form.schoolCode = res.schoolCode
      } else {
        this.$router.push({
          name: "School"
        });
      }
    },
  }
}
